<?php
if(!check_manager_login()) exit('无权查看，请登录!');
require_once(MODEL_PATH.DS.'News.php');
$News = new News();

$news_id = isset($_GET['news_id'])?(int)$_GET['news_id']:'';

if(check_post()){
	$news_cate = $_POST['news_cate'];
	$title = trim($_POST['news_title']);
	$short_desc = trim($_POST['short_desc']);
	$description = trim($_POST['description']);
	if(!($title||$short_desc||$description)){}
	$data = array(
		'news_id'=>$news_id,
		'cate_id'=>$news_cate,
		'title'  =>$title,
		'short_desc'=>$short_desc,
		'description'=>$description,
	);
	$result = $News->updateNews($data);
	if($result){
		redirect('index.php?mod=news&act=list','编辑新闻成功!');
	}
}
$news_info = $News->getNewsById($news_id);
$cate_all = $News->getAllNewsCate();
$cate_select = create_select($cate_all,'id','name',$news_info['cate_id']);

include load_tpl('news_add');
?>